package com.icinfo.cloud.provider.common.zlb.controller;
/*
 * Copyright© 2003-2017 浙江汇信科技有限公司, All Rights Reserved.
 */

import com.icinfo.cloud.provider.common.zlb.service.ZlbEntLoginService;
import com.icinfo.framework.common.web.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 【V1.1.0】（安吉速结）描述: 浙里办登录
 *
 */

@RestController
@RequestMapping("/app/ZlbLogin")
public class ZlbEntController {
    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private ZlbEntLoginService zlbLoginService;

    /**
     * 【V1.1.0】（安吉速结） 获取浙里办法人用户
     *
     * @param ticketId
     * @return
     * @author zhengqiang
     * @date 2023-02-07
     **/
    @GetMapping(value = "/legal/legalLoginAnJi")
    public Result getLoginOfLegal(@RequestParam String ticketId) {
        Object legalUser = zlbLoginService.getLegalUser(ticketId);
        return Result.success(legalUser);
    }

    /**
     * 【V1.1.0】（安吉速结） 浙里办个人用户登录回调
     *
     * @param request
     * @param response
     * @return
     * @author zhengqiang
     * @date 2023-02-07
     **/
    @GetMapping(value = "/personal/loginAnJi")
    public void personalLogin(HttpServletRequest request, HttpServletResponse response) throws Exception {
        response.setHeader("refresh", "1;URL=" + zlbLoginService.getPersonalRedirectUrl(request));
    }

}
